#include<bits/stdc++.h>
using namespace std;
namespace IO{
    const int BUF=1<<21;
    char buff[BUF],*p1=buff,*p2=buff;
    #define gc() (p1==p2&&(p2=((p1=buff)+fread(buff,1,BUF,stdin)),p1==p2)?EOF:*p1++)
    template<typename T>inline void read(T &x){
        char ch=gc();x=0;int f=1;
        while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
        while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=gc();
        x*=f;
    }
    char obuf[BUF],*p3=obuf;
    inline void pc(char ch){
        if(p3-obuf<BUF) *p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    inline void put(const char *s){while(*s) pc(*s),++s;}
    char ch[32],ctop;
    template<typename T>inline void print(T x){
    	if(x<0) x=~x+1,pc('-');
        if(!x) return pc(48);
        while(x) ch[++ctop]=x%10^48,x/=10;
        while(ctop) pc(ch[ctop--]);
    }
    inline void flush(){fwrite(obuf,p3-obuf,1,stdout);p3=obuf;}
}
using namespace IO;
const int N=2e5+5;
int n,a[N],b[N],ans[N],lt[N],rt[N],stk[N],top;
int main(){
	freopen("min.in","r",stdin);
	freopen("min.out","w",stdout);
	read(n);
	for(int i=1;i<=n;++i) read(a[i]);
	for(int i=1;i<=n;++i) read(b[i]);
	if(n<=2000){
		memset(ans,0x3f,sizeof(ans));
		for(int i=1;i<=n;++i){
			int m1=2e9,m2=2e9;
			for(int j=i;j<=n;++j){
				m1=min(m1,a[j]);
				m2=min(m2,b[j]);
				ans[j-i+1]=min(ans[j-i+1],abs(m1-m2));
			}
		}
		for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
		return 0;
	}
	bool sub1=1;
	for(int i=1;i<=n;++i) sub1&=(b[i]==1);
	if(sub1){
		int mi=2e9;
		for(int i=1;i<=n;++i) mi=min(mi,a[i]);
		for(int i=1;i<=n;++i) print(mi-1),pc('\n');
		flush();
		return 0;
	}
	memset(ans,0x3f,sizeof(ans));
	for(int i=1;i<=n;++i){
		while(top&&a[stk[top]]>a[i]) rt[stk[top--]]=i;
		lt[i]=stk[top],rt[i]=n+1;
		stk[++top]=i;
	}
	const int _1e9=1000000000;
	for(int i=1;i<=n;++i){
		int len=rt[i]-lt[i]-1;
		ans[len]=min(ans[len],_1e9-a[i]);
	}
	for(int i=n-1;i;--i) ans[i]=min(ans[i+1],ans[i]);
	for(int i=1;i<=n;++i) print(ans[i]),pc('\n');
	flush();
	return 0;
}


